<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::X509::Certificate - openssl: Ruby Standard Library Documentation</title>


<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<script src="../../js/jquery-3.2.0.min.js"></script>

<script src="../../js/vue.min.js"></script>
<script src="../../js/js.cookie.min.js"></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../../css/rdoc.css" rel="stylesheet">
<link href="../../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
  var darkModeCsseHref = "../../css/rdoc-dm.css"
  var defaultModeCssHref = "../../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#class-OpenSSL::X509::Certificate-label-Reading+a+certificate+from+a+file">Reading a certificate from a file</a>
    <li><a href="#class-OpenSSL::X509::Certificate-label-Saving+a+certificate+to+a+file">Saving a certificate to a file</a>
    <li><a href="#class-OpenSSL::X509::Certificate-label-Creating+a+root+CA+certificate+and+an+end-entity+certificate">Creating a root CA certificate and an end-entity certificate</a>
  </ul>
</div>


    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
    <li><a class="include" href="../Marshal.html">OpenSSL::Marshal</a>
    <li><a class="include" href="Extension/SubjectKeyIdentifier.html">OpenSSL::X509::Extension::SubjectKeyIdentifier</a>
    <li><a class="include" href="Extension/AuthorityKeyIdentifier.html">OpenSSL::X509::Extension::AuthorityKeyIdentifier</a>
    <li><a class="include" href="Extension/CRLDistributionPoints.html">OpenSSL::X509::Extension::CRLDistributionPoints</a>
    <li><a class="include" href="Extension/AuthorityInfoAccess.html">OpenSSL::X509::Extension::AuthorityInfoAccess</a>
  </ul>
</div>

        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-load">::load</a>
    <li ><a href="#method-c-load_file">::load_file</a>
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-3D-3D">#==</a>
    <li ><a href="#method-i-add_extension">#add_extension</a>
    <li ><a href="#method-i-check_private_key">#check_private_key</a>
    <li ><a href="#method-i-extensions">#extensions</a>
    <li ><a href="#method-i-extensions-3D">#extensions=</a>
    <li ><a href="#method-i-initialize_copy">#initialize_copy</a>
    <li ><a href="#method-i-inspect">#inspect</a>
    <li ><a href="#method-i-issuer">#issuer</a>
    <li ><a href="#method-i-issuer-3D">#issuer=</a>
    <li ><a href="#method-i-not_after">#not_after</a>
    <li ><a href="#method-i-not_after-3D">#not_after=</a>
    <li ><a href="#method-i-not_before">#not_before</a>
    <li ><a href="#method-i-not_before-3D">#not_before=</a>
    <li ><a href="#method-i-pretty_print">#pretty_print</a>
    <li ><a href="#method-i-public_key">#public_key</a>
    <li ><a href="#method-i-public_key-3D">#public_key=</a>
    <li ><a href="#method-i-serial">#serial</a>
    <li ><a href="#method-i-serial-3D">#serial=</a>
    <li ><a href="#method-i-sign">#sign</a>
    <li ><a href="#method-i-signature_algorithm">#signature_algorithm</a>
    <li ><a href="#method-i-subject">#subject</a>
    <li ><a href="#method-i-subject-3D">#subject=</a>
    <li ><a href="#method-i-to_der">#to_der</a>
    <li ><a href="#method-i-to_pem">#to_pem</a>
    <li ><a href="#method-i-to_s">#to_s</a>
    <li ><a href="#method-i-to_text">#to_text</a>
    <li ><a href="#method-i-verify">#verify</a>
    <li ><a href="#method-i-version">#version</a>
    <li ><a href="#method-i-version-3D">#version=</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-OpenSSL::X509::Certificate">
    <h1 id="class-OpenSSL::X509::Certificate" class="class">
      class OpenSSL::X509::Certificate
    </h1>

    <section class="description">
    
<p>Implementation of an X.509 certificate as specified in RFC 5280. Provides access to a certificate’s attributes and allows certificates to be read from a string, but also supports the creation of new certificates from scratch.</p>

<h3 id="class-OpenSSL::X509::Certificate-label-Reading+a+certificate+from+a+file">Reading a certificate from a file<span><a href="#class-OpenSSL::X509::Certificate-label-Reading+a+certificate+from+a+file">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p><a href="Certificate.html"><code>Certificate</code></a> is capable of handling DER-encoded certificates and certificates encoded in OpenSSL’s PEM format.</p>

<pre class="ruby"><span class="ruby-identifier">raw</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">binread</span> <span class="ruby-string">&quot;cert.cer&quot;</span> <span class="ruby-comment"># DER- or PEM-encoded</span>
<span class="ruby-identifier">certificate</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Certificate</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">raw</span>
</pre>

<h3 id="class-OpenSSL::X509::Certificate-label-Saving+a+certificate+to+a+file">Saving a certificate to a file<span><a href="#class-OpenSSL::X509::Certificate-label-Saving+a+certificate+to+a+file">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>A certificate may be encoded in DER format</p>

<pre class="ruby"><span class="ruby-identifier">cert</span> = <span class="ruby-operator">...</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">&quot;cert.cer&quot;</span>, <span class="ruby-string">&quot;wb&quot;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">print</span> <span class="ruby-identifier">cert</span>.<span class="ruby-identifier">to_der</span> }
</pre>

<p>or in PEM format</p>

<pre class="ruby"><span class="ruby-identifier">cert</span> = <span class="ruby-operator">...</span>
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-string">&quot;cert.pem&quot;</span>, <span class="ruby-string">&quot;wb&quot;</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">print</span> <span class="ruby-identifier">cert</span>.<span class="ruby-identifier">to_pem</span> }
</pre>

<p>X.509 certificates are associated with a private/public key pair, typically a RSA, DSA or ECC key (see also <a href="../PKey/RSA.html"><code>OpenSSL::PKey::RSA</code></a>, <a href="../PKey/DSA.html"><code>OpenSSL::PKey::DSA</code></a> and <a href="../PKey/EC.html"><code>OpenSSL::PKey::EC</code></a>), the public key itself is stored within the certificate and can be accessed in form of an <a href="../PKey.html"><code>OpenSSL::PKey</code></a>. Certificates are typically used to be able to associate some form of identity with a key pair, for example web servers serving pages over HTTPs use certificates to authenticate themselves to the user.</p>

<p>The public key infrastructure (PKI) model relies on trusted certificate authorities (“root CAs”) that issue these certificates, so that end users need to base their trust just on a selected few authorities that themselves again vouch for subordinate CAs issuing their certificates to end users.</p>

<p>The <a href="../X509.html"><code>OpenSSL::X509</code></a> module provides the tools to set up an independent PKI, similar to scenarios where the ‘openssl’ command line tool is used for issuing certificates in a private PKI.</p>

<h3 id="class-OpenSSL::X509::Certificate-label-Creating+a+root+CA+certificate+and+an+end-entity+certificate">Creating a root CA certificate and an end-entity certificate<span><a href="#class-OpenSSL::X509::Certificate-label-Creating+a+root+CA+certificate+and+an+end-entity+certificate">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>First, we need to create a “self-signed” root certificate. To do so, we need to generate a key first. Please note that the choice of “1” as a serial number is considered a security flaw for real certificates. Secure choices are integers in the two-digit byte range and ideally not sequential but secure random numbers, steps omitted here to keep the example concise.</p>

<pre class="ruby"><span class="ruby-identifier">root_key</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKey</span><span class="ruby-operator">::</span><span class="ruby-constant">RSA</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">2048</span> <span class="ruby-comment"># the CA&#39;s public/private key</span>
<span class="ruby-identifier">root_ca</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Certificate</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">version</span> = <span class="ruby-value">2</span> <span class="ruby-comment"># cf. RFC 5280 - to make it a &quot;v3&quot; certificate</span>
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">serial</span> = <span class="ruby-value">1</span>
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">subject</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Name</span>.<span class="ruby-identifier">parse</span> <span class="ruby-string">&quot;/DC=org/DC=ruby-lang/CN=Ruby CA&quot;</span>
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">issuer</span> = <span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">subject</span> <span class="ruby-comment"># root CA&#39;s are &quot;self-signed&quot;</span>
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">public_key</span> = <span class="ruby-identifier">root_key</span>.<span class="ruby-identifier">public_key</span>
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">not_before</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">not_after</span> = <span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">not_before</span> <span class="ruby-operator">+</span> <span class="ruby-value">2</span> <span class="ruby-operator">*</span> <span class="ruby-value">365</span> <span class="ruby-operator">*</span> <span class="ruby-value">24</span> <span class="ruby-operator">*</span> <span class="ruby-value">60</span> <span class="ruby-operator">*</span> <span class="ruby-value">60</span> <span class="ruby-comment"># 2 years validity</span>
<span class="ruby-identifier">ef</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">ExtensionFactory</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">subject_certificate</span> = <span class="ruby-identifier">root_ca</span>
<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">issuer_certificate</span> = <span class="ruby-identifier">root_ca</span>
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">add_extension</span>(<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">create_extension</span>(<span class="ruby-string">&quot;basicConstraints&quot;</span>,<span class="ruby-string">&quot;CA:TRUE&quot;</span>,<span class="ruby-keyword">true</span>))
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">add_extension</span>(<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">create_extension</span>(<span class="ruby-string">&quot;keyUsage&quot;</span>,<span class="ruby-string">&quot;keyCertSign, cRLSign&quot;</span>, <span class="ruby-keyword">true</span>))
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">add_extension</span>(<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">create_extension</span>(<span class="ruby-string">&quot;subjectKeyIdentifier&quot;</span>,<span class="ruby-string">&quot;hash&quot;</span>,<span class="ruby-keyword">false</span>))
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">add_extension</span>(<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">create_extension</span>(<span class="ruby-string">&quot;authorityKeyIdentifier&quot;</span>,<span class="ruby-string">&quot;keyid:always&quot;</span>,<span class="ruby-keyword">false</span>))
<span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">sign</span>(<span class="ruby-identifier">root_key</span>, <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Digest</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;SHA256&#39;</span>))
</pre>

<p>The next step is to create the end-entity certificate using the root CA certificate.</p>

<pre class="ruby"><span class="ruby-identifier">key</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">PKey</span><span class="ruby-operator">::</span><span class="ruby-constant">RSA</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">2048</span>
<span class="ruby-identifier">cert</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Certificate</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">version</span> = <span class="ruby-value">2</span>
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">serial</span> = <span class="ruby-value">2</span>
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">subject</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Name</span>.<span class="ruby-identifier">parse</span> <span class="ruby-string">&quot;/DC=org/DC=ruby-lang/CN=Ruby certificate&quot;</span>
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">issuer</span> = <span class="ruby-identifier">root_ca</span>.<span class="ruby-identifier">subject</span> <span class="ruby-comment"># root CA is the issuer</span>
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">public_key</span> = <span class="ruby-identifier">key</span>.<span class="ruby-identifier">public_key</span>
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">not_before</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">not_after</span> = <span class="ruby-identifier">cert</span>.<span class="ruby-identifier">not_before</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span> <span class="ruby-operator">*</span> <span class="ruby-value">365</span> <span class="ruby-operator">*</span> <span class="ruby-value">24</span> <span class="ruby-operator">*</span> <span class="ruby-value">60</span> <span class="ruby-operator">*</span> <span class="ruby-value">60</span> <span class="ruby-comment"># 1 years validity</span>
<span class="ruby-identifier">ef</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">ExtensionFactory</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">subject_certificate</span> = <span class="ruby-identifier">cert</span>
<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">issuer_certificate</span> = <span class="ruby-identifier">root_ca</span>
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">add_extension</span>(<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">create_extension</span>(<span class="ruby-string">&quot;keyUsage&quot;</span>,<span class="ruby-string">&quot;digitalSignature&quot;</span>, <span class="ruby-keyword">true</span>))
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">add_extension</span>(<span class="ruby-identifier">ef</span>.<span class="ruby-identifier">create_extension</span>(<span class="ruby-string">&quot;subjectKeyIdentifier&quot;</span>,<span class="ruby-string">&quot;hash&quot;</span>,<span class="ruby-keyword">false</span>))
<span class="ruby-identifier">cert</span>.<span class="ruby-identifier">sign</span>(<span class="ruby-identifier">root_key</span>, <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Digest</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&#39;SHA256&#39;</span>))
</pre>

    </section>

      <section id="5Buntitled-5D" class="documentation-section">





                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-load" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          OpenSSL::X509::Certificate.load(string) &rarr; [certs...]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          OpenSSL::X509::Certificate.load(file) &rarr; [certs...]
                              </span>
                            </div>

                            <div class="method-description">
                              <p>Read the chained certificates from the given input. Supports both PEM and DER encoded certificates.</p>

<p>PEM is a text format and supports more than one certificate.</p>

<p>DER is a binary format and only supports one certificate.</p>

<p>If the file is empty, or contains only unrelated data, an <code>OpenSSL::X509::CertificateError</code> exception will be raised.</p>

                              <div class="method-source-code" id="load-source">
            <pre>static VALUE
ossl_x509_load(VALUE klass, VALUE buffer)
{
    BIO *in = ossl_obj2bio(&amp;buffer);

    return rb_ensure(load_chained_certificates, (VALUE)in, load_chained_certificates_ensure, (VALUE)in);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-load_file" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">load_file</span><span
                                class="method-args">(path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="load_file-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/x509.rb, line 360</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">load_file</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">binread</span>(<span class="ruby-identifier">path</span>))
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-c-new" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          new &rarr; cert
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>
                      <div class="method-heading">
                        <span class="method-callseq">
                          new(string) &rarr; cert
                              </span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre>static VALUE
ossl_x509_initialize(int argc, VALUE *argv, VALUE self)
{
    BIO *in;
    X509 *x509, *x509_orig = RTYPEDDATA_DATA(self);
    VALUE arg;

    rb_check_frozen(self);
    if (rb_scan_args(argc, argv, &quot;01&quot;, &amp;arg) == 0) {
        /* create just empty X509Cert */
        return self;
    }
    arg = ossl_to_der_if_possible(arg);
    in = ossl_obj2bio(&amp;arg);
    x509 = d2i_X509_bio(in, NULL);
    if (!x509) {
        OSSL_BIO_reset(in);
        x509 = PEM_read_bio_X509(in, NULL, NULL, NULL);
    }
    BIO_free(in);
    if (!x509)
        ossl_raise(eX509CertError, &quot;PEM_read_bio_X509&quot;);

    RTYPEDDATA_DATA(self) = x509;
    X509_free(x509_orig);

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-3D-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          cert1 == cert2 &rarr; true | false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Compares the two certificates. Note that this takes into account all fields, not just the issuer name and the serial number.</p>

                              <div class="method-source-code" id="3D-3D-source">
            <pre>static VALUE
ossl_x509_eq(VALUE self, VALUE other)
{
    X509 *a, *b;

    GetX509(self, a);
    if (!rb_obj_is_kind_of(other, cX509Cert))
        return Qfalse;
    GetX509(other, b);

    return !X509_cmp(a, b) ? Qtrue : Qfalse;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-add_extension" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          add_extension(extension) &rarr; extension
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="add_extension-source">
            <pre>static VALUE
ossl_x509_add_extension(VALUE self, VALUE extension)
{
    X509 *x509;
    X509_EXTENSION *ext;

    GetX509(self, x509);
    ext = GetX509ExtPtr(extension);
    if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext - FREE it */
        ossl_raise(eX509CertError, NULL);
    }

    return extension;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-check_private_key" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          check_private_key(key) &rarr; true | false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Returns <code>true</code> if <em>key</em> is the corresponding private key to the Subject Public Key Information, <code>false</code> otherwise.</p>

                              <div class="method-source-code" id="check_private_key-source">
            <pre>static VALUE
ossl_x509_check_private_key(VALUE self, VALUE key)
{
    X509 *x509;
    EVP_PKEY *pkey;

    /* not needed private key, but should be */
    pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
    GetX509(self, x509);
    if (!X509_check_private_key(x509, pkey)) {
        ossl_clear_error();
        return Qfalse;
    }

    return Qtrue;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-extensions" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          extensions &rarr; [extension...]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="extensions-source">
            <pre>static VALUE
ossl_x509_get_extensions(VALUE self)
{
    X509 *x509;
    int count, i;
    X509_EXTENSION *ext;
    VALUE ary;

    GetX509(self, x509);
    count = X509_get_ext_count(x509);
    if (count &lt; 0) {
        return rb_ary_new();
    }
    ary = rb_ary_new2(count);
    for (i=0; i&lt;count; i++) {
        ext = X509_get_ext(x509, i); /* NO DUP - don&#39;t free! */
        rb_ary_push(ary, ossl_x509ext_new(ext));
    }

    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-extensions-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          extensions = [ext...] &rarr; [ext...]
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="extensions-3D-source">
            <pre>static VALUE
ossl_x509_set_extensions(VALUE self, VALUE ary)
{
    X509 *x509;
    X509_EXTENSION *ext;
    long i;

    Check_Type(ary, T_ARRAY);
    /* All ary&#39;s members should be X509Extension */
    for (i=0; i&lt;RARRAY_LEN(ary); i++) {
        OSSL_Check_Kind(RARRAY_AREF(ary, i), cX509Ext);
    }
    GetX509(self, x509);
    for (i = X509_get_ext_count(x509); i &gt; 0; i--)
        X509_EXTENSION_free(X509_delete_ext(x509, 0));
    for (i=0; i&lt;RARRAY_LEN(ary); i++) {
        ext = GetX509ExtPtr(RARRAY_AREF(ary, i));
        if (!X509_add_ext(x509, ext, -1)) { /* DUPs ext */
            ossl_raise(eX509CertError, &quot;X509_add_ext&quot;);
        }
    }

    return ary;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-initialize_copy" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">initialize_copy</span><span
                                class="method-args">(p1)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="initialize_copy-source">
            <pre>static VALUE
ossl_x509_copy(VALUE self, VALUE other)
{
    X509 *a, *b, *x509;

    rb_check_frozen(self);
    if (self == other) return self;

    GetX509(self, a);
    GetX509(other, b);

    x509 = X509_dup(b);
    if (!x509) ossl_raise(eX509CertError, NULL);

    DATA_PTR(self) = x509;
    X509_free(a);

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-inspect" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">inspect</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="inspect-source">
            <pre>static VALUE
ossl_x509_inspect(VALUE self)
{
    return rb_sprintf(&quot;#&lt;%&quot;PRIsVALUE&quot;: subject=%+&quot;PRIsVALUE&quot;, &quot;
                      &quot;issuer=%+&quot;PRIsVALUE&quot;, serial=%+&quot;PRIsVALUE&quot;, &quot;
                      &quot;not_before=%+&quot;PRIsVALUE&quot;, not_after=%+&quot;PRIsVALUE&quot;&gt;&quot;,
                      rb_obj_class(self),
                      ossl_x509_get_subject(self),
                      ossl_x509_get_issuer(self),
                      ossl_x509_get_serial(self),
                      ossl_x509_get_not_before(self),
                      ossl_x509_get_not_after(self));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-issuer" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          issuer &rarr; name
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="issuer-source">
            <pre>static VALUE
ossl_x509_get_issuer(VALUE self)
{
    X509 *x509;
    X509_NAME *name;

    GetX509(self, x509);
    if(!(name = X509_get_issuer_name(x509))) { /* NO DUP - don&#39;t free! */
        ossl_raise(eX509CertError, NULL);
    }

    return ossl_x509name_new(name);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-issuer-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          issuer = name &rarr; name
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="issuer-3D-source">
            <pre>static VALUE
ossl_x509_set_issuer(VALUE self, VALUE issuer)
{
    X509 *x509;

    GetX509(self, x509);
    if (!X509_set_issuer_name(x509, GetX509NamePtr(issuer))) { /* DUPs name */
        ossl_raise(eX509CertError, NULL);
    }

    return issuer;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-not_after" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          not_after &rarr; time
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="not_after-source">
            <pre>static VALUE
ossl_x509_get_not_after(VALUE self)
{
    X509 *x509;
    const ASN1_TIME *asn1time;

    GetX509(self, x509);
    if (!(asn1time = X509_get0_notAfter(x509))) {
        ossl_raise(eX509CertError, NULL);
    }

    return asn1time_to_time(asn1time);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-not_after-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          not_after = time &rarr; time
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="not_after-3D-source">
            <pre>static VALUE
ossl_x509_set_not_after(VALUE self, VALUE time)
{
    X509 *x509;
    ASN1_TIME *asn1time;

    GetX509(self, x509);
    asn1time = ossl_x509_time_adjust(NULL, time);
    if (!X509_set1_notAfter(x509, asn1time)) {
        ASN1_TIME_free(asn1time);
        ossl_raise(eX509CertError, &quot;X509_set_notAfter&quot;);
    }
    ASN1_TIME_free(asn1time);

    return time;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-not_before" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          not_before &rarr; time
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="not_before-source">
            <pre>static VALUE
ossl_x509_get_not_before(VALUE self)
{
    X509 *x509;
    const ASN1_TIME *asn1time;

    GetX509(self, x509);
    if (!(asn1time = X509_get0_notBefore(x509))) {
        ossl_raise(eX509CertError, NULL);
    }

    return asn1time_to_time(asn1time);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-not_before-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          not_before = time &rarr; time
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="not_before-3D-source">
            <pre>static VALUE
ossl_x509_set_not_before(VALUE self, VALUE time)
{
    X509 *x509;
    ASN1_TIME *asn1time;

    GetX509(self, x509);
    asn1time = ossl_x509_time_adjust(NULL, time);
    if (!X509_set1_notBefore(x509, asn1time)) {
        ASN1_TIME_free(asn1time);
        ossl_raise(eX509CertError, &quot;X509_set_notBefore&quot;);
    }
    ASN1_TIME_free(asn1time);

    return time;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-pretty_print" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">pretty_print</span><span
                                class="method-args">(q)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="pretty_print-source">
            <pre><span class="ruby-comment"># File openssl/lib/openssl/x509.rb, line 349</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">pretty_print</span>(<span class="ruby-identifier">q</span>)
  <span class="ruby-identifier">q</span>.<span class="ruby-identifier">object_group</span>(<span class="ruby-keyword">self</span>) {
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">breakable</span>
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;subject=&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">pp</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">subject</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;,&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">breakable</span>
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;issuer=&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">pp</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">issuer</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;,&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">breakable</span>
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;serial=&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">pp</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">serial</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;,&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">breakable</span>
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;not_before=&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">pp</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">not_before</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;,&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">breakable</span>
    <span class="ruby-identifier">q</span>.<span class="ruby-identifier">text</span> <span class="ruby-string">&#39;not_after=&#39;</span>; <span class="ruby-identifier">q</span>.<span class="ruby-identifier">pp</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">not_after</span>
  }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-public_key" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_key &rarr; key
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="public_key-source">
            <pre>static VALUE
ossl_x509_get_public_key(VALUE self)
{
    X509 *x509;
    EVP_PKEY *pkey;

    GetX509(self, x509);
    if (!(pkey = X509_get_pubkey(x509))) { /* adds an reference */
        ossl_raise(eX509CertError, NULL);
    }

    return ossl_pkey_new(pkey); /* NO DUP - OK */
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-public_key-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          public_key = key
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="public_key-3D-source">
            <pre>static VALUE
ossl_x509_set_public_key(VALUE self, VALUE key)
{
    X509 *x509;
    EVP_PKEY *pkey;

    GetX509(self, x509);
    pkey = GetPKeyPtr(key);
    ossl_pkey_check_public_key(pkey);
    if (!X509_set_pubkey(x509, pkey))
        ossl_raise(eX509CertError, &quot;X509_set_pubkey&quot;);
    return key;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-serial" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          serial &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="serial-source">
            <pre>static VALUE
ossl_x509_get_serial(VALUE self)
{
    X509 *x509;

    GetX509(self, x509);

    return asn1integer_to_num(X509_get_serialNumber(x509));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-serial-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          serial = integer &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="serial-3D-source">
            <pre>static VALUE
ossl_x509_set_serial(VALUE self, VALUE num)
{
    X509 *x509;

    GetX509(self, x509);
    X509_set_serialNumber(x509, num_to_asn1integer(num, X509_get_serialNumber(x509)));

    return num;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-sign" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          sign(key, digest) &rarr; self
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="sign-source">
            <pre>static VALUE
ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
{
    X509 *x509;
    EVP_PKEY *pkey;
    const EVP_MD *md;

    pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
    md = ossl_evp_get_digestbyname(digest);
    GetX509(self, x509);
    if (!X509_sign(x509, pkey, md)) {
        ossl_raise(eX509CertError, NULL);
    }

    return self;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-signature_algorithm" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          signature_algorithm &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="signature_algorithm-source">
            <pre>static VALUE
ossl_x509_get_signature_algorithm(VALUE self)
{
    X509 *x509;
    BIO *out;
    VALUE str;

    GetX509(self, x509);
    out = BIO_new(BIO_s_mem());
    if (!out) ossl_raise(eX509CertError, NULL);

    if (!i2a_ASN1_OBJECT(out, X509_get0_tbs_sigalg(x509)-&gt;algorithm)) {
        BIO_free(out);
        ossl_raise(eX509CertError, NULL);
    }
    str = ossl_membio2str(out);

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-subject" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          subject &rarr; name
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="subject-source">
            <pre>static VALUE
ossl_x509_get_subject(VALUE self)
{
    X509 *x509;
    X509_NAME *name;

    GetX509(self, x509);
    if (!(name = X509_get_subject_name(x509))) { /* NO DUP - don&#39;t free! */
        ossl_raise(eX509CertError, NULL);
    }

    return ossl_x509name_new(name);
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-subject-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          subject = name &rarr; name
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="subject-3D-source">
            <pre>static VALUE
ossl_x509_set_subject(VALUE self, VALUE subject)
{
    X509 *x509;

    GetX509(self, x509);
    if (!X509_set_subject_name(x509, GetX509NamePtr(subject))) { /* DUPs name */
        ossl_raise(eX509CertError, NULL);
    }

    return subject;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_der" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_der &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="to_der-source">
            <pre>static VALUE
ossl_x509_to_der(VALUE self)
{
    X509 *x509;
    VALUE str;
    long len;
    unsigned char *p;

    GetX509(self, x509);
    if ((len = i2d_X509(x509, NULL)) &lt;= 0)
        ossl_raise(eX509CertError, NULL);
    str = rb_str_new(0, len);
    p = (unsigned char *)RSTRING_PTR(str);
    if (i2d_X509(x509, &amp;p) &lt;= 0)
        ossl_raise(eX509CertError, NULL);
    ossl_str_adjust(str, p);

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-to_pem" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_pem &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="to_pem-source">
            <pre>static VALUE
ossl_x509_to_pem(VALUE self)
{
    X509 *x509;
    BIO *out;
    VALUE str;

    GetX509(self, x509);
    out = BIO_new(BIO_s_mem());
    if (!out) ossl_raise(eX509CertError, NULL);

    if (!PEM_write_bio_X509(out, x509)) {
        BIO_free(out);
        ossl_raise(eX509CertError, NULL);
    }
    str = ossl_membio2str(out);

    return str;
}</pre>
                              </div>
                            </div>

                            <div class="aliases">
                              Also aliased as: <a href="Certificate.html#method-i-to_s">to_s</a>
                            </div>

                          </div>

                  <div id="method-i-to_s" class="method-detail method-alias">
                            <div class="method-heading">
                              <span class="method-name">to_s</span><span
                                class="method-args">()</span>
                            </div>

                            <div class="method-description">
                              

                            </div>


                            <div class="aliases">
                              Alias for: <a href="Certificate.html#method-i-to_pem">to_pem</a>
                            </div>
                          </div>

                  <div id="method-i-to_text" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          to_text &rarr; string
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="to_text-source">
            <pre>static VALUE
ossl_x509_to_text(VALUE self)
{
    X509 *x509;
    BIO *out;
    VALUE str;

    GetX509(self, x509);

    out = BIO_new(BIO_s_mem());
    if (!out) ossl_raise(eX509CertError, NULL);

    if (!X509_print(out, x509)) {
        BIO_free(out);
        ossl_raise(eX509CertError, NULL);
    }
    str = ossl_membio2str(out);

    return str;
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-verify" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          verify(key) &rarr; true | false
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              <p>Verifies the signature of the certificate, with the public key <em>key</em>. <em>key</em> must be an instance of <a href="../PKey.html"><code>OpenSSL::PKey</code></a>.</p>

                              <div class="method-source-code" id="verify-source">
            <pre>static VALUE
ossl_x509_verify(VALUE self, VALUE key)
{
    X509 *x509;
    EVP_PKEY *pkey;

    GetX509(self, x509);
    pkey = GetPKeyPtr(key);
    ossl_pkey_check_public_key(pkey);
    switch (X509_verify(x509, pkey)) {
      case 1:
        return Qtrue;
      case 0:
        ossl_clear_error();
        return Qfalse;
      default:
        ossl_raise(eX509CertError, NULL);
    }
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-version" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          version &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="version-source">
            <pre>static VALUE
ossl_x509_get_version(VALUE self)
{
    X509 *x509;

    GetX509(self, x509);

    return LONG2NUM(X509_get_version(x509));
}</pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-version-3D" class="method-detail ">
                      <div class="method-heading">
                        <span class="method-callseq">
                          version = integer &rarr; integer
                              </span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="version-3D-source">
            <pre>static VALUE
ossl_x509_set_version(VALUE self, VALUE version)
{
    X509 *x509;
    long ver;

    if ((ver = NUM2LONG(version)) &lt; 0) {
        ossl_raise(eX509CertError, &quot;version must be &gt;= 0!&quot;);
    }
    GetX509(self, x509);
    if (!X509_set_version(x509, ver)) {
        ossl_raise(eX509CertError, NULL);
    }

    return version;
}</pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

